package descentFly.app
{
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	
	import UIUtils.uif_util;
	
	import descentFly.df_utils;
	
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class df_label extends uif_label {
		public static const DEFAULTHEIGHT: int = 20;
		public function df_label(parent:uif_component, ax:int=0, ay:int=0, awidth:int=0, aheight: int=DEFAULTHEIGHT, a_styleClass: Object ='label') {
			super(parent, ax, ay, awidth, aheight, a_styleClass);
		}
		
		override protected function updateTextFieldBounds(): void {
			if (style.text_format && !style.text_format.multiline) {
				var size: Point = uif_util.calcTextSize(text, style);
				if (size.x > 0) {
					var inner: Rectangle = getInner();
					if (size.x > inner.width) {
						textField.width  = size.x;
						textField.height = size.y;
						
						textField.scaleX = inner.width / size.x;
						textField.scaleY = textField.scaleX;
					} else {
						textField.scaleX = 1;
						textField.scaleY = 1;
					}
				}
			}
			super.updateTextFieldBounds();
		}
	}
}